#------------------------------------------------------------------------------
# Study 1 Balance statistics
#------------------------------------------------------------------------------

.fmla <- assigned.to.session ~ same.party + Party7pt + Age + Education + Income +
  White + Black + Latino + Other + Female + path.to.citizenship.baseline.01 +
  trust.baseline.01 + approval.baseline.01 + vote.baseline.01
xBalance(.fmla, strata = list(~congressional.district), data = d1, 
         report = c('chisquare.test'))
table4 <- xBalance(.fmla, strata = list(~congressional.district), data = d1, 
  report = c('adj.means', 'z.scores', 'p.values'))$results
table4 <- as.data.frame(table4)
table4 <- round(table4, 3)
names(table4) <- c('Assigned to Control', 'Assigned to Treatment', 'Z', 'P')
rownames(table4)[1:14] <- c('Same Party as MOC', 'Party (7 point scale)',
  'Age Category (4 point scale)', 'Education (4 point scale)',
  'Income (9 point scale)', 'White', 'Black', 'Latino', 'Other Race',
  'Female', 'Path to Citizenship (baseline)', 'Trust MOC (baseline)',
  'Approve (baseline)', 'Vote Intent (baseline)')

#------------------------------------------------------------------------------
# Study 2 Balance statistics
#------------------------------------------------------------------------------

.fmla <- assigned.to.session ~ same.party + Party7pt + Age + Education + Income +
  White + Black + Latino + Other + Female + torture.baseline.01 +
  trust.baseline.01 + approval.baseline.01 + vote.baseline.01
xBalance(.fmla, data = d2, report = c('chisquare.test'))
table5 <- xBalance(.fmla, data = d2, 
                   report = c('adj.means', 'z.scores', 'p.values'))$results
table5 <- as.data.frame(table5)
table5 <- round(table5, 3)
names(table5) <- c('Assigned to Control', 'Assigned to Treatment', 'Z', 'P')
rownames(table5)[1:14] <- c('Same Party as MOC', 'Party (7 point scale)',
  'Age Category (4 point scale)', 'Education (4 point scale)',
  'Income (9 point scale)', 'White', 'Black', 'Latino', 'Other Race',
  'Female', 'Torture Justifiable (baseline)','Trust MOC (baseline)',
  'Approve (baseline)', 'Vote Intent (baseline)')
